Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 24, 2025

Fixes #86655287 by adding code examples demonstrating common wildcard pattern usage in F#.

Changes Made

Enhanced the Wildcard Pattern section in docs/fsharp/language-reference/pattern-matching.md by adding a new F# code sample (snippet4818.fs) that demonstrates wildcard usage patterns:

  • Function parameters: When _ is used in parameter lists, it ignores arguments entirely
  • Data structure destructuring: When _ ignores specific elements that aren't needed
  • Pattern matching: Using _ to ignore values in match expressions

Code Example

// Wildcard ignoring function parameters
let ignoreAllParams _ _ = "Ignores all input"

// Wildcard in destructuring, ignoring elements
let getFirstOnly (first, _) = first

// Using wildcard to ignore optional values
let handleEmpty opt =
    match opt with
    | Some _ -> "Has something"
    | None -> "Has nothing"

This addresses the gap in documentation referenced in dotnet/fsharp#1592 by providing additional examples of wildcard pattern usage, a commonly used feature in F# for ignoring unwanted values and parameters.

The changes maintain backward compatibility and follow existing documentation patterns while providing additional practical examples of the wildcard underscore _ pattern.

Fixes #20858

Fixes #20858


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/fsharp/language-reference/pattern-matching.md docs/fsharp/language-reference/pattern-matching

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Sep 24, 2025
@Copilot Copilot AI changed the title [WIP] Add wildcard's ability to match nothing Add documentation for wildcard pattern's ability to match nothing Sep 24, 2025
@Copilot Copilot AI requested a review from BillWagner September 24, 2025 20:28
Copilot finished work on behalf of BillWagner September 24, 2025 20:28
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM and is ready for final review.

@BillWagner BillWagner marked this pull request as ready for review September 25, 2025 14:44
@BillWagner BillWagner requested review from a team as code owners September 25, 2025 14:44
@Copilot Copilot AI requested a review from T-Gro October 3, 2025 06:47
Copilot finished work on behalf of T-Gro October 3, 2025 06:47
@Copilot Copilot AI changed the title Add documentation for wildcard pattern's ability to match nothing Add wildcard pattern usage examples to F# documentation Oct 3, 2025
Copilot finished work on behalf of T-Gro October 3, 2025 07:02
@Copilot Copilot AI requested a review from T-Gro October 3, 2025 07:02
@T-Gro T-Gro enabled auto-merge (squash) October 3, 2025 07:03
@T-Gro T-Gro merged commit a700eed into main Oct 3, 2025
18 checks passed
@T-Gro T-Gro deleted the copilot/fix-86655287-d2fb-4c69-9f9a-df36043e1740 branch October 3, 2025 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-fsharp/svc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add wildcard's ability to match nothing
3 participants